﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace ElingOA6_DSJCJ.Common
{
    public class myDisk
    {
        public static bool CreateDir(string path)
        {
            if (Directory.Exists(path))
            {
                return true;
            }
            else
            {
                try
                {
                    Directory.CreateDirectory(path);
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }

        public static bool DelDir(string path)
        {
            if (!Directory.Exists(path))
            {
                return true;
            }
            else
            {
                try
                {
                    Directory.Delete(path);
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }

        public static bool MoveDir(string sourcePath, string destPath)
        {
            try
            {
                Directory.Move(sourcePath, destPath);
                return true;
            }
            catch
            {
                return false;
            }
        }

        //public static bool CopyDir(string sourcePath, string destPath)
        //{
        //    return false;
        //}

        public static bool DelFile(string path)
        {
            if (!File.Exists(path))
            {
                return true;
            }
            else
            {
                try
                {
                    File.Delete(path);
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }

        public static bool MoveFile(string sourcePath, string destPath)
        {
            try
            {
                if (File.Exists(destPath))
                    File.Delete(destPath);

                File.Move(sourcePath, destPath);

                if (File.Exists(sourcePath))
                    File.Delete(sourcePath);

                return true;

            }
            catch
            {
                return false;
            }
        }

        public static bool CopyFile(string sourcePath, string destPath)
        {
            try
            {
                File.Copy(sourcePath, destPath, true);
                return true;
            }
            catch
            {
                return false;
            }
        }




    }
}